<!---creates a new user account--->
<cfinclude template="validate.cfm">
<cfif waserror IS 1>
	<cfset showform = 1>
<cfelse>
	<cfinvoke component="cfcs.common.dbqueries" method="insertdata" tablename="core_accounts" returnvariable="newid"/>
    <cfinvoke component="cfcs.common.encryption" method="encryptstring" textstring="#form.password#" returnvariable="enc_password" />

	<!---create unique userid and store it along with encrypted password in user account--->
	<cfset epochs = DateDiff("s", "January 1 1974 00:00", Now())>
	<cfset suffix1 = FormatBaseN((RandRange(1,100000000) + epochs),36)>
    <cfset newuserid = "#lcase(suffix1)#">

	<cfset suffix3 = InputBaseN(suffix1, 36)>
	<cfset newuuid = "#suffix3#">
    
    <cfset signupdate = now()>
    <cfquery name = "qryInsertNewuser" datasource="#request.dsn#">
    UPDATE core_accounts
    SET pword = '#enc_password#', 
    aid = #newuuid#
    WHERE id = <cfqueryparam value="#newid#" cfsqltype="cf_sql_integer">
    </cfquery>
    <cfinvoke component="cfcs.common.shared" method="redirect" msg="Account has been created." url="index.cfm?c=accounts&start=#start#&disp=#disp#&sortby=#sortby#&sortorder=#sortorder#&viewtype=#viewtype#" />
</cfif>